using System;
using System.Windows.Forms;

namespace LazyPlugins.AutoAttacher.UI
{
    public partial class WaitToAttach : Form
    {
        private int waitTimeout;

        public void SafeClose()
        {
            if(this.InvokeRequired)
                this.Invoke(new Action(this.Close), new object[] { });
            else
                this.Close();
        }

        public WaitToAttach(int waitTimeout)
        {
            InitializeComponent();
            this.waitTimeout = waitTimeout;
            lblWaitTimeout.Text = waitTimeout.ToString();
        }

        private void WaitToAttach_Load(object sender, EventArgs e)
        {
            
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if(waitTimeout <= 0)
                this.Close();
            else
            {
                waitTimeout--;
                lblWaitTimeout.Text = waitTimeout.ToString();
            }
        }
    }
}